
var getDate=[];
var labelname="";
require.config({
    paths:{
        echarts: Feng.ctxPath+'/static/js/plugins/echarts-2.2.7/build/dist'
    }
});

var option = {
    title : {
        text: '商品销售分析'
    },
    tooltip : {
        trigger: 'axis'
    },
    legend: {
        data:[]
    },
    toolbox: {
        show : true,
        feature : {
            mark : {show: true},
            dataView : {show: true, readOnly: false},
            magicType : {show: true, type: ['line', 'bar']},
            restore : {show: true},
            saveAsImage : {show: true}
        }
    },
    calculable : true,
    xAxis : [
        {
            type : 'category',
            data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
        }
    ],
    yAxis : [
        {
            type : 'value'
        }
    ],
    series : [
        {
            name: labelname,
            type:'bar',
            data: getDate,
            markPoint : {
                data : [
                    {type : 'max', name: '最大值'},
                    {type : 'min', name: '最小值'}
                ]
            },
            markLine : {
                data : [
                    {type : 'average', name: '平均值'}
                ]
            }
        }
    ]
};

$(function () {
    var ajax = new $ax(Feng.ctxPath + "/analysis/getallsale", function (data) {
        $('#money').text(data['money']);
        $('#orders').text(data['orders']);
        $('#people').text(data['people']);
        option['legend']['data'].push(data['yearsale']);
        option['series'][0]['name']=data['yearsale'];
        option['series'][0]['data']=data['saledate'];
        echarone();
    });
    ajax.start()
});
var echarone = function(){
    require(
        [
            'echarts',
            'echarts/chart/bar',
            'echarts/chart/line',
            'echarts/chart/pie',
            'echarts/chart/map',

        ],
        function(ec) {
            var myChart = ec.init(document.getElementById('yearale'));
            myChart.setOption(option);
        }

    );
};

